3600 // On-disk file system format.
3601 // Both the kernel and user programs use this header file.
3602 
3603 // Block 0 is unused.
3604 // Block 1 is super block.
3605 // Inodes start at block 2.
3606 
3607 #define ROOTINO 1  // root i-number
3608 #define BSIZE 512  // block size
3609 
3610 // File system super block
3611 struct superblock {
3612   uint size;         // Size of file system image (blocks)
3613   uint nblocks;      // Number of data blocks
3614   uint ninodes;      // Number of inodes.
3615 };
3616 
3617 #define NDIRECT 12
3618 #define NINDIRECT (BSIZE / sizeof(uint))
3619 #define MAXFILE (NDIRECT + NINDIRECT)
3620 
3621 // On-disk inode structure
3622 struct dinode {
3623   short type;           // File type
3624   short major;          // Major device number (T_DEV only)
3625   short minor;          // Minor device number (T_DEV only)
3626   short nlink;          // Number of links to inode in file system
3627   uint size;            // Size of file (bytes)
3628   uint addrs[NDIRECT+1];   // Data block addresses
3629 };
3630 
3631 // Inodes per block.
3632 #define IPB           (BSIZE / sizeof(struct dinode))
3633 
3634 // Block containing inode i
3635 #define IBLOCK(i)     ((i) / IPB + 2)
3636 
3637 // Bitmap bits per block
3638 #define BPB           (BSIZE*8)
3639 
3640 // Block containing bit for block b
3641 #define BBLOCK(b, ninodes) (b/BPB + (ninodes)/IPB + 3)
3642 
3643 // Directory is a file containing a sequence of dirent structures.
3644 #define DIRSIZ 14
3645 
3646 struct dirent {
3647   ushort inum;
3648   char name[DIRSIZ];
3649 };
